﻿#include <iostream>
#include <string>
#include <map>
using namespace std;
// 海军军舰番号由两部分组成： 团队 +军舰群

// Part01:团队
class Person
{
public:
  string name;
  string job;
  string ability;
  string reward;
  Person() = default;
  Person(const string &name_, const string &job_, const string &ability_, const string &reward_)
  {
    name = name_;
    job = job_;
    ability = ability_;
    reward = reward_;
  }
  ~Person() {}
};
class Team
{
protected:
  string name_team;
  map<string, Person *> members;

public:
  Team(const Team &team)
  { // 拷贝构造函数
    this->name_team = team.name_team;
    for (auto iter = team.members.begin(); iter != team.members.end(); iter++)
    {
      this->members[iter->first] = new Person(*(iter->second)); // 拷贝对象
    }
  }
  Team(Team &&team)
  { // 移动构造函数
    this->name_team = team.name_team;
    team.name_team.~basic_string();
    this->members = std::move(team.members);
  }
  Team(const string &name_) : name_team(name_) {}
  void addMember(Person *person)
  {
    this->members.insert({person->name, person});
  }
  void show()
  {
    for (auto person : members)
    {
      cout << person.first << "\t" << person.second->job << "\t" << person.second->reward << "\t" << person.second->job << "\n";
    }
  }
  virtual void executeTask() = 0;
};
class HeihuTeam : public Team
{
public:
  using Team::Team;
  void executeTask() override
  {
    cout << "我们将执行黑虎队的任务：打入敌人内部，实现里应外合，消灭敌人！" << endl;
  }
};
class YanziTeam : public Team
{
public:
  using Team::Team;
  void executeTask() override
  {
    cout << "我们将执行燕子对的任务：捕获猎物，获取情报，定点消除地方重要人物！" << endl;
  }
};
// Part02: 军舰
class AbWarship
{
protected:
  Team *team = nullptr;

public:
  AbWarship(Team *team_) : team(team_) {}
  void showTeam()
  {
    team->show();
  }
  virtual string getName() = 0;
  virtual void feature() = 0;
};
class HeihuWarship : public AbWarship
{
public:
  using AbWarship::AbWarship;
  string getName() override
  {
    return string("进击-黑虎舰");
  }
  void feature() override
  {
    cout << getName() << ":::火力加满，把对方打成筛子！" << endl;
  }
};
class YanziWarship : public AbWarship
{
public:
  using AbWarship::AbWarship;
  string getName() override
  {
    return string("猎人-燕子舰");
  }
  void feature() override
  {
    cout << getName() << ":::截获敌方重要情报，把敌人后方捅成筛子！" << endl;
  }
};
int main()
{
  // 创建团队
  Person *captain = new Person("张穿", "船长", "能力是张扬", "12000刀");
  Person *driver = new Person("佳私园", "驾驶员", "开船如履平地", "8000刀");
  Person *seaman = new Person("税首", "水手", "干苦力我罪行", "1000刀");
  Team *heihu_team = new HeihuTeam("黑虎舰队");
  heihu_team->addMember(captain);
  heihu_team->addMember(driver);
  heihu_team->addMember(seaman);
  HeihuWarship *warship_heihu = new HeihuWarship(heihu_team);
  warship_heihu->getName();
  warship_heihu->showTeam();
  warship_heihu->feature();
  return 0;
}
